package code;

public class Main {

    static class node {
        int val=0;
        node next = null;

        public node(int val) {
            this.val = val;
        }
        public node(int val, node next) {
            this.val = val;
            this.next = next;
        }
    }


    public static void main(String[] args) {
        node n3 = new node(3);
        node n2 = new node(2,n3);
        node n1 = new node(1,n2);
        node head = new node(0,n1);

        node t = head;
        System.out.println();
        while (t.next!= null) {
            System.out.print(t.next.val);
            t = t.next;
        }

        node tep = head.next;
        node next = null;
        while (tep != null) {
            node i = tep.next;
            tep.next=next;
            head.next=tep;
            next = tep;
            tep = i;
        }

        node y = head;
        System.out.println();
        while (y.next!= null) {
            System.out.print(y.next.val);
            y = y.next;
        }




    }

}
